---
title: Agentic RAG
---

This example application shows how to build a sophisticated RAG (Retrieval Augmented Generation) system that leverages search of a knowledge base with LLMs to provide deep insights into the data.


## The agent can:
- Process and understand documents from multiple sources (PDFs, websites, text files)
- Build a searchable knowledge base using vector embeddings
- Maintain conversation context and memory across sessions
- Provide relevant citations and sources for its responses
- Generate summaries and extract key insights
- Answer follow-up questions and clarifications

## The agent uses:
- Vector similarity search for relevant document retrieval
- Conversation memory for contextual responses
- Citation tracking for source attribution
- Dynamic knowledge base updates

<video
  autoPlay
  muted
  controls
  className="w-full aspect-video"
  src="/videos/agentic_rag.mp4"
></video>

## Example queries to try:
- "What are the key points from this document?"
- "Can you summarize the main arguments and supporting evidence?"
- "What are the important statistics and findings?"
- "How does this relate to [topic X]?"
- "What are the limitations or gaps in this analysis?"
- "Can you explain [concept X] in more detail?"
- "What other sources support or contradict these claims?"

## Code

The complete code is available in the [Agno repository](https://github.com/agno-agi/agno).

## Usage

<Steps>
  <Step title="Clone the repository">
    ```bash
    git clone https://github.com/agno-agi/agno.git
    cd agno
    ```
  </Step>

  <Step title="Create virtual environment">
    ```bash
    python3 -m venv .venv
    source .venv/bin/activate
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash
    pip install -r cookbook/examples/streamlit_apps/agentic_rag/requirements.txt
    ```
  </Step>

  <Step title="Run PgVector">
    First, install [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/).

    Then run either using the helper script:
    ```bash
    ./cookbook/scripts/run_pgvector.sh
    ```

    Or directly with Docker:
    ```bash
    docker run -d \
      -e POSTGRES_DB=ai \
      -e POSTGRES_USER=ai \
      -e POSTGRES_PASSWORD=ai \
      -e PGDATA=/var/lib/postgresql/data/pgdata \
      -v pgvolume:/var/lib/postgresql/data \
      -p 5532:5432 \
      --name pgvector \
      agnohq/pgvector:16
    ```
  </Step>


  <Step title="Set up API keys">
    ```bash
    # Required
    export OPENAI_API_KEY=***
    # Optional
    export ANTHROPIC_API_KEY=***
    export GOOGLE_API_KEY=***

    ```
    We recommend using gpt-5-mini for optimal performance.
  </Step>

  <Step title="Launch the app">
    ```bash
    streamlit run cookbook/examples/streamlit_apps/agentic_rag/app.py
    ```
    Open localhost:8501 to start using the Agentic RAG.
  </Step>
</Steps>

Need help? Join our [Discourse community](https://community.agno.com) for support!
